Skip to content

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Jun 6, 2025

In the existing ANR detection we need to collect some state from the threads. This is used to collect debug meta and the current session.

Rather than use registerThread() to repeatedly poll from each thread, registerThread() is used to register the thread and threadPoll() is used to poll. threadPoll() can optionally take a state object which is stored with the thread information. v8::JSON::stringify is used to serialise the state. Later when calling captureStackTrace(), for each thread the frame and any state are returned.

@timfish timfish requested a review from AbhiPrasad June 9, 2025 23:00

std::string state_str;
if (args.Length() == 1 && args[0]->IsValue()) {
MaybeLocal<String> maybe_json = v8::JSON::Stringify(context, args[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if a return a huge json? Should we account for size limits in some way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to think about this but I think the worse case is too much memory use or OOM.

@timfish timfish merged commit 3bf5ed9 into main Jun 11, 2025
62 checks passed
@timfish timfish deleted the feat/track-thread-state branch June 11, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants